import {
  Body,
  Controller,
  Delete,
  Get,
  Post,
  Put,
  Query,
  UseInterceptors,
} from '@nestjs/common';
import { FakeService } from './fake.service';
import { AuthInterceptor } from '../../config/filter/auth.interceptor';

@Controller('/api/v1/fake')
export class FakeController {
  constructor(private readonly fakeService: FakeService) {}
  @Get('/U9/page')
  @UseInterceptors(AuthInterceptor)
  u9Page(@Query('sql') sql: string, @Query('countSql') countSql: string) {
    return this.fakeService.queryU9PageService(sql, countSql);
  }
  @Get('/U9')
  @UseInterceptors(AuthInterceptor)
  u9List(@Query('sql') sql: string) {
    return this.fakeService.queryU9ListService(sql);
  }

  @Get('/page')
  @UseInterceptors(AuthInterceptor)
  page(@Query('sql') sql: string, @Query('countSql') countSql: string) {
    return this.fakeService.queryPageService(sql, countSql);
  }

  @Get('')
  @UseInterceptors(AuthInterceptor)
  list(@Query('sql') sql: string) {
    return this.fakeService.queryListService(sql);
  }

  @Post('')
  @UseInterceptors(AuthInterceptor)
  add(@Query('sql') sql: string) {
    return this.fakeService.updateService(sql);
  }

  @Put('')
  @UseInterceptors(AuthInterceptor)
  update(@Query('sql') sql: string) {
    return this.fakeService.updateService(sql);
  }

  @Delete('')
  @UseInterceptors(AuthInterceptor)
  softDelete(@Body() params: Map<string, any>) {
    return this.fakeService.softDeleteService(params);
  }
}
